<?php 
include '../db-connection/conn.php';
session_start();
//  Developed by Roshan Bhattarai 
//  Visit http://roshanbh.com.np for this script and more.
//  This notice MUST stay intact for legal use

// if session is not set redirect the user
if(empty($_SESSION['u_name']))
	header("Location:index.php");	

//if logout then destroy the session and redirect the user
if(isset($_GET['logout']))
{
	session_destroy();
	header("Location:index.php?logout=true");
}	
?>
<?php
$path = "http://".$_SERVER["HTTP_HOST"]."/gibbons";
?>
<?php
include 'includes/header.php';
?>
<table cellpadding="0" cellspacing="0" width="100%" border="0" >
<tr>
<td colspan="2">
<?php
$str = "<a href='home.php?logout' style='text-align:right;'><b>Logout<b></a>";
echo "<div align='right'>Welcome ".$_SESSION['name'].", ".$str."</div>";
?>
</td>
</tr>
<tr>
<td width="15%" valign="top">
<?php
include 'includes/menu.php';
?>
</td>
<td valign="top">
<div id="tabs">

<?php
include 'includes/tabs.php';
if(isset($_REQUEST['id']))
{
	if($_REQUEST['id'] != "")
	{
		$sqlF = "SELECT * FROM tbl_products_vehicle WHERE id=".$_REQUEST['id'];
		$resultF = mysql_query($sqlF);
		$qryF = mysql_fetch_array($resultF);
	}	
}

?>
<script>
$("#tab1").addClass( "ui-tabs-selected ui-state-active" );
</script>
<form id="form1" name="form1" action="">

<?php
$sql="SELECT * FROM tbl_products WHERE parent=0 AND is_Active=1";
$result = mysql_query($sql);
$str ="";
$str .= "<select id='strProducts' name='strProducts' onchange='subProductsDetails(this.value);'>";
$str .= "<option value=''>Select Products</option>";
while ($qry = mysql_fetch_array($result)) {
	
if($qryF["productid"] == $qry['id'])	
	$selected="selected='selected'";
	else
	$selected = "";
	
$str .= "<option value='".$qry['id']."' $selected >";
$str .= $qry["name"];
$str .= "</option>";
}
$str .= "</select>";
?>
<table cellpadding="3" cellspacing="0" width="100%">
<tr align="center">
<td colspan="2" width="120px">

			<input type="radio" border="1" id="VehicleStatus" name="VehicleStatus" value="NEW" checked="checked" />&nbsp;New Vehicle
			
</tr>
<tr>
<td>
Products
</td>
<td>
<?php print $str; ?>
</td>
</tr>

<tr>
<td>
Sub Products
</td>
<td id="subProducts">
<select id='strsubProducts' name='strsubProducts' >
<?php  if(isset($_REQUEST["id"])){
	$sqlM="SELECT * FROM tbl_products WHERE parent=".$qryF["productid"]." AND is_Active=1";
	$resultM = mysql_query($sqlM);
	$str1 ="";
	while ($qryM = mysql_fetch_array($resultM)) 
	{		
		if($qryF["subproductid"] == $qryM['id'])	
		{
			$selected= "selected='selected'";
		}
		else
		{
			$selected= "";
		}
		$str1 .= "<option value='".$qryM['id']."' >";
		$str1 .= $qryM["name"];
		$str1 .= "</option>";
	}	
		print $str1.$sqlS;
	
 } else { ?>
<option value=''>Select Products first
</option>
<?php print $str1.$sqlS; 
} ?>
</select>
</td>
</tr>

<tr>
<td>
Year
</td>
<td>
<input type="text" name="txtYear" id="txtYear" onkeypress="return isNumberKey(event)" value="<?php echo stripslashes($qryF["year"]); ?>"/>
</td>
</tr>

<tr>
<td>
Series
</td>
<td>
<input type="text" name="txtSeries" id="txtSeries" onblur="chkProducts();" value="<?php echo stripslashes($qryF["series"]); ?>"/>
</td>
</tr>
<tr>
<td>
Title
</td>
<td>
<input type="text" name="txtTitle" id="txtTitle" onblur="chkProducts();" value="<?php echo stripslashes($qryF["title"]); ?>"/>
</td>
</tr>
<tr>
<td>
Original Price
</td>
<td>
<input type="text" id="txtoriginalprice" name="txtoriginalprice" value="<?php echo stripslashes($qryF["original_price"]); ?>"/>
</td>
</tr>
<tr>
<td>
Offered Price
</td>
<td>
<input type="text" id="txtofferedprice" name="txtofferedprice" value="<?php echo stripslashes($qryF["offered_price"]); ?>"/>
</td>
</tr>
<tr>
<td colspan="2">
<input type="button" name="submit" id="submit" class="submit" value="submit" onclick="saveProducts('<?php print $path; ?>');">	
</td>
</tr>
</table>

</form>

</div>
</td>
</tr>
</table>
<?php
include 'includes/footer.php';
?>

